package com.shujia.scala

object Demo4For {
  def main(args: Array[String]): Unit = {

    //快速构建序列
    //含头含尾
    val arr = 1 to 100
    println(arr)
    //含头不含尾
    println(1 until 10)

    //循环一个序列
    for (i <- 3 to 10) {
      println(i)
    }

    //1、冒泡排序
    //List:不可变列表列表
    val l = Array(2, 123, 21, 412, 321, 41, 23, 124, 12, 3, 124, 123)

    //indices:获取下标
    for (i <- l.indices) {
      for (j <- 0 until l.length - (i + 1)) {
        if (l(j) > l(j + 1)) {
          val tmp: Int = l(j)
          l(j) = l(j + 1)
          l(j + 1) = tmp
        }
      }
    }
    println(l.toList)



  }
}
